function inline_editing_edit(){
	if(this.in_edit)return;
	this.in_edit=true;
	var str=this.innerHTML;
	var w=$(this).innerWidth();
	this.originalHTML=str;
	$(this).empty();
	$('<input>')
		.attr('value',str)
		.blur(inline_editing_save)
		.keypress(inline_editing_key_pressed)
		.css('width',w)
		.appendTo(this)
		.focus();
}
function inline_editing_save(){
	var id,field_name,p;
	p=this.parentNode;
	if(p.originalHTML==this.value)
		return inline_editing_restore(p);
	field_name=p.className;
	id=$(this).closest('tr')[0].id.replace(/.*_/,'');
	$.getJSON(
		inline_editing_url,
		{'id':id,'field_name':field_name,'value':this.value},
		function(data){
			if(!data.success){
				inline_editing_restore(el);
				return alert(data.error);
			}
			$(p)
				.empty()
				.text(data.value);
			p.in_edit=false;
		}
	);
}
function inline_editing_key_pressed(e){
	if(!e.which)inline_editing_restore(this.parentNode);
}
function inline_editing_restore(el){
	$(el).html(el.originalHTML);
	el.in_edit=false;
}
var inline_editing_url='';
